package net.tv90.bfmccore.squad;

import net.tv90.bfmccore.util.HUD.TextShow;
import net.tv90.bfmccore.util.vector.Vector2i;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.List;

public class SquadShowTask implements Runnable {

    @Override
    public void run() {
        for (Player player : Bukkit.getOnlinePlayers()) {
            List<String> squadMember = Squad.getSquadMember(player);
            if (squadMember != null) {
                //s.append(leader).append("★\n");
                List<TextShow> tss = new ArrayList<>();
                TextShow name = new TextShow(new Vector2i(10, 150), "\u00a7a" + Squad.getSquad(player) + "小队[" + squadMember.size() + "/" + Squad.SQUAD_MAX_SIZE + "]", 1.0, "squadInfo", 1);
                tss.add(name);
                for (int i = 0; i < squadMember.size(); i++) {
                    if (i == 0) {
                        tss.add(new TextShow(new Vector2i(10, 160), "\u00a7a" + squadMember.get(i) + " ★", 1.0, "squadInfo_0", 1));
                    } else {
                        tss.add(new TextShow(new Vector2i(10, 150 + (i + 1) * 10), "\u00a7a" + squadMember.get(i), 1.0, "squadInfo_" + i, 1));
                    }
                }
                for (TextShow textShow : tss) {
                    textShow.show(player);
                }

            }
        }
    }


}
